﻿#ifndef __SS_TIMER_THREAD_H__
#define __SS_TIMER_THREAD_H__
//#include "../../ssBaseDefine.h"
#include "../../message/ssMsgIdDef.h"
#include "../../thread/ssThreadBase.h"
#include "../../thread/threadLock/ssThreadCondition.h"
#include "../../container/ssHeap.h"
#include "../../tools/ssIDAlloter.h"
#include "../ssTimerDispatch.h"

namespace StarSeeker
{

class ssTimerThread : public ssThreadBase
{
public:
	ssTimerThread();
	virtual ~ssTimerThread();
	//注册消息处理类
	void BindDispatch(ssTimerDispatch* dis);
	//启动半点计时器
	void StartHalfTimer();
	//添加计时器
	u32 AddNewTimer(u32 msgType, u32 interval, ulint param1, ulint param2);
	//删除计时器
	void RemoveTimer(u32 timerId);
	//停止线程
	void ExitThread();
	//当前任务数
	ulint GetTimerCount();
protected:
	//添加计时器
	u32 AddTimer(u32 msgType, u32 time, u32 interval, ulint p1, ulint p2);

	virtual void ThreadMemberFunc();

protected:
	ssThreadLock			m_mutex;		//互斥量
	ssThreadCondition		m_condGet;		//读取条件变量
	ssNumHeap<ssTimer_s>	m_msgHeap;		//消息堆
	ssCumulationID<u32>		m_ids;
	ssTimerDispatch	*		m_pDispatch;
};

}
#endif
